#######################
# This creates Figure 6, comparing results of question wording experiment 1
#######################

##Find mean support for use of force, unconditional on question wording
force.plot<-svymean(~tf,nd)

#format line with sort order (3), mean, se supporting use of force
line1<-c(3,force.plot[1],SE(force.plot))

##find mean support for use of force, conditional on question wording
line2<-svyby(~tf,~p_over,nd,svymean)

#bind these results together
fig6<-rbind(line2,line1)

#calculate 95% confidence intervals
fig6$ci_lo<-(fig6$tf-(1.96*fig6$se))
fig6$ci_hi<-(fig6$tf+(1.96*fig6$se))

#create plot of means, confidence intervals
#Note - this converts raw values to percentage by multiplying by 100
fig6plot <- ggplot(fig6, aes(x = as.factor(p_over), y=tf*100,color=as.factor(p_over),shape=as.factor(p_over)))+
  ylim(0,10)+
  geom_point(size = 2) + 
  theme_bw()+
  theme(legend.position="none")+
  theme(axis.title.x=element_blank(),axis.title.y=element_blank())+
  theme(plot.title = element_text(hjust = 0.5))+
  geom_linerange(aes(ymin = ci_lo*100, ymax = ci_hi*100))+
  scale_x_discrete(labels=c("Even If People Are Hurt or Killed","No consequences","All Respondents")) +
  ggtitle("% Agree or Strongly Agree \n The use of force is justified to restore \n Donald Trump to the presidency")

#save results
ggsave("../Main Results/Fig6.tif", width=6, height=4, units = "in",dpi=600)





